小弟在統計臨櫃匯出匯款筆數、金額時卡住了.....
想詢問版上的大大,下圖為最終顯示結果
小弟該如何下指令會比較好....
下方是小弟目前算出匯出的幣別並折成美金
SELECT A.REMIT_CCY,COUNT(0) ,
CASE WHEN REMIT_CCY ='AUD' THEN SUM(ROUND(REMIT_AMT * B.EXRATE_EVALUATE,2))
WHEN REMIT_CCY ='CAD' THEN SUM(ROUND(REMIT_AMT / B.EXRATE_EVALUATE,2))
WHEN REMIT_CCY ='CHF' THEN SUM(ROUND(REMIT_AMT / B.EXRATE_EVALUATE,2))
WHEN REMIT_CCY ='CNY' THEN SUM(ROUND(REMIT_AMT / B.EXRATE_EVALUATE,2))
WHEN REMIT_CCY ='EUR' THEN SUM(ROUND(REMIT_AMT * B.EXRATE_EVALUATE,2))
WHEN REMIT_CCY ='GBP' THEN SUM(ROUND(REMIT_AMT * B.EXRATE_EVALUATE,2))
WHEN REMIT_CCY ='HKD' THEN SUM(ROUND(REMIT_AMT / B.EXRATE_EVALUATE,2))
WHEN REMIT_CCY ='JPY' THEN SUM(ROUND(REMIT_AMT / B.EXRATE_EVALUATE,2))
WHEN REMIT_CCY ='NZD' THEN SUM(ROUND(REMIT_AMT * B.EXRATE_EVALUATE,2))
WHEN REMIT_CCY ='SGD' THEN SUM(ROUND(REMIT_AMT / B.EXRATE_EVALUATE,2))
WHEN REMIT_CCY ='ZAR' THEN SUM(ROUND(REMIT_AMT / B.EXRATE_EVALUATE,2))
WHEN REMIT_CCY ='USD' THEN SUM(ROUND(REMIT_AMT * B.EXRATE_EVALUATE,2)) END AS 折美金額
FROM FRORTM A
LEFT JOIN CMXRVM_CBUS B ON A.REMIT_CCY=B.CCY AND B.VALID_DATE ='20240200'
WHERE TXNT_DATE>='20240201' and TXNT_DATE<='20240231' GROUP BY REMIT_CCY ORDER BY REMIT_CCY
下圖是區分法金 / 個金 判別方式
select CLIENT_CODE,sum(CNT) from ( select case when SUBSTRING(REMITTER_ID,9,1)=' ' then '法金' else '個金' end as CLIENT_CODE, count(*) as CNT from FRORTM where TXNT_DATE>='20240201' and TXNT_DATE<='20240231' group by SUBSTRING(REMITTER_ID,9,1) ) as d group by CLIENT_CODE ORDER BY 1